﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Globalization;
using System.Diagnostics;

namespace CountdownCalendar.Converters
{
    public static class StringToDateTime
    {
        public static bool GetDateTime(string stringDate, out DateTime convertedDate)
        {
            Debug.WriteLine("Begin - StringToDateTime");
            DateTime date;
            CultureInfo enUS = new CultureInfo("en-US");
            bool isValid = DateTime.TryParseExact(stringDate, "MM/dd/yyyy", enUS, DateTimeStyles.None, out date);
            if (isValid)
            {
                convertedDate = date;
                Debug.WriteLine("End - StringToDateTime");
                return true;
            }
            else
            {
                convertedDate = new DateTime();
                Debug.WriteLine("End - StringToDateTime");
                return false;
            }
            
        }
    }
}
